<include file="../header" />
<body style="margin-bottom:5px">
<script type="text/javascript">
    function processPage(id, page) {
        var url = "/admin/workorder/process?id=" + id + "&page=" + page + "&home=1";
        window.location.href = url;
    }
    $(window).resize(function() {
        window.location.reload()
    });
    $(document).ready(function(){
        if($(window).width() < 1200){
            $(".icon1-th").hide();
            $(".icon2-th").show();
            $(".icon1-br").show();
            $(".icon1-img").height(40);
            $(".icon1-img").width(40);
        }else{
            $(".icon1-th").show();
            $(".icon2-th").hide();
            $(".icon1-br").hide();
            $(".icon1-img").height(50);
            $(".icon1-img").width(50);
        }
    });
</script>
<style type="text/css">
    .btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 70px;
        height: 19px;
        line-height: 19px;
        font-size: small;
        padding: 0px 1px 0px 1px;
        margin: 0px 0px 0px 0px;
    }
    td{
        border: solid 1px #e1e2ff;
    }
</style>
<form style="width: 100%;height: auto;float:left; margin-bottom: 0px" class="well form-search" method="post"  action="{:U('Workorder/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span style="width: 1rem" class="mr20">
            状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：{:getEnumSelectWidget($statusEnum, "wo#status", $status, 1)}
            工 单 号：<input type="text" name="wo#workorder_no-like" value="{$workorder_no}" />
            患者姓名：<input type="text" name="pt#patient_name-like" value="{$patient_name}" />
            <br>
            类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型：{:getEnumSelectWidget($typeEnum, "wo#workorder_type", $type, 1)}开始时间：<input type="text" value="{$begin_time}" class="date J_date" name="wo#create_time-egt" />
            结束时间：<input type="text" value="{$end_time}" class="date J_date" name="wo#create_time-elt" />
            <button class="btn btn-primary" type="submit">搜索</button>
            <a class="btn" href="{:U('Workorder/index')}">重置</a>
        </span>
        </div>
    </div>
</form>
<div class="wrap J_check_wrap" style="padding: 1px 1px 0px 1px; overflow-x:auto;white-space:nowrap;">
    <php>$imgVersion = "2020101301";</php>
    <table class="table table-hover table-bordered" style="margin-bottom: 0px; border: solid 1px #e1e2ff;">
        <thead>
        <tr>
            <th style="line-height: 10px; min-width: 415px;border: solid 1px #e1e2ff;">工单信息</th>
            <th style="line-height: 10px; min-width: 152px; width: 152px; color: #45a1de; border: solid 1px #e1e2ff;">工单状态</th>
            <th class="icon1-th" style="line-height: 10px; min-width: 410px; width: 410px;border: solid 1px #e1e2ff;">制作与入库</th>
            <th class="icon2-th" style="line-height: 10px; min-width: 160px; width: 160px;border: solid 1px #e1e2ff; display: none">制作与入库</th>
            <th style="line-height: 10px; min-width: 60px; width: 60px;border: solid 1px #e1e2ff; text-align: center">操作</th>
            <th style="line-height: 10px; min-width: 60px; width: 60px;border: solid 1px #e1e2ff; text-align: center">审核</th>
        </tr>
        </thead>
        <tbody>
        <php>
            $colorCheck = 0;
        </php>
        <foreach name="workorderList" item="vo">
            <php>
                if($colorCheck == 0){
                    $color = "#FCFCFF";
                    $colorCheck = 1;
                }else{
                    $color = "#FEFDFE";
                    $colorCheck = 0;
                }
            </php>
            <tr bgcolor="{$color}">
                <td style="padding: 0px 5px 0px 5px;">单号: {$vo.workorder_no} <a style="color: #e97c7d">{$vo.side}</a><if condition="$vo['delivery_date'] neq ''"> &nbsp;预计交付: <a>{$vo.delivery_date}</a></if>
                    <br>
                    患者{$num}: <a style="font-weight: bold" title="{$vo.sex}, {$vo.age}岁, {$vo.diagnosis}">{$vo.patient_name}</a>,
                    <if condition="$vo['workorder_type'] neq '3'">
                        类型: <a style="color: #FFA451">{$vo.type_name}</a>, 价格: <a style="color: #e97c7d">{$vo.price}</a>
                    </if>
                    <if condition="$vo['payment_status'] neq ''">
                        , <a>{$vo.payment_status}</a>
                    </if>
                    <if condition="$vo['deposit'] neq ''">
                        : <a style="color: #e97c7d">{$vo.deposit}</a>
                    </if>
                    <br>
                    检测: <a style="color: #45a1de">{$vo.examinator}</a>, 处方: <a style="color: #45a1de">{$vo.prescriber}</a>, 业务员: <a style="color: #45a1de">{$vo.sales}</a><if condition="$vo['reviewer'] neq ''">, 工序检查: <a>{$vo.reviewer}</a></if><if condition="$vo['auditor'] neq ''">, 质量检查: <a>{$vo.auditor}</a></if>
                    <br>
                    <if condition="$vo['status'] eq '-2'">
                        <a style="color: #e97c7d">工单已关闭</a>
                    </if>
                </td>
                <php>
                    $statusArr = array();
                    $statusArr["1"] = "出处方";
                    $statusArr["2"] = "已接单";
                    $statusArr["3"] = "制作中";
                    $statusArr["4"] = "完成";
                    $statusArr[$vo["status"]] .= "亮";
                </php>
                <td style="padding: 5px 2px 0px 0px;">
                    <img style="height: 50px" src="/Template/images/{$statusArr.1}.png?v={$imgVersion}"/>
                    <img style="height: 50px" src="/Template/images/arrow.png"/>
                    <!--<img style="height: 90px" src="/Template/images/{$statusArr.2}.png?v={$imgVersion}"/>-->
                    <!--<img style="height: 90px" src="/Template/images/arrow.png"/>-->
                    <img style="height: 50px" src="/Template/images/{$statusArr.3}.png?v={$imgVersion}"/>
                    <img style="height: 50px" src="/Template/images/arrow.png"/>
                    <img style="height: 50px" src="/Template/images/{$statusArr.4}.png?v={$imgVersion}"/>
                </td>
                <php>
                    $processStatusArr=explode(",",$vo["process_status"]);
                    if(in_array($vo["workorder_type"],array('1','5','6','7')))
                        $processArr = array("取阴模", "检查取阴模","修阳模","检查修阳模","热塑成型","检查热塑成型","打磨抛光","检查打磨抛光","组装对线","半成品适配","穿戴及使用训练","入库");
                    if(in_array($vo["workorder_type"],array('2','4')))
                        $processArr = array("取阴模2", "检查取阴模2","修阳模2","检查修阳模2","热塑成型","检查热塑成型","打磨抛光","检查打磨抛光","组装对线","半成品适配2","穿戴及使用训练2","入库");
                    if(in_array($vo["workorder_type"],array('8','9','10','11')))
                        $processArr = array("接受腔制作", "装配","假肢入库");
                    for($i = 0; $i < 12; $i++){
                        if($processStatusArr[$i] == "1"){
                            $processArr[$i] .= "亮";
                        }
                    }
                </php>
                <td style="padding: 5px 2px 0px 0px;">
                    <if condition="$orthosisProcess[0] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.0}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",1)' title="取阴模"/>
                    </if>
                    <if condition="$orthosisProcess[1] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.1}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",2)' title="检查取阴模"/>
                    </if>
                    <if condition="$orthosisProcess[2] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.2}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",3)' title="修阳模"/>
                    </if>
                    <if condition="$orthosisProcess[3] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.3}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",4)' title="检查修阳模"/>
                    </if>
                    <if condition="$orthosisProcess[4] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.4}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",5)' title="热塑成型"/>
                    </if>
                    <if condition="$orthosisProcess[5] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.5}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",6)' title="检查热塑成型"/>
                    </if>
                    <if condition="$orthosisProcess[6] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.6}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",7)' title="打磨抛光"/>
                    </if>
                    <br class="icon1-br" style="display: none">
                    <if condition="$orthosisProcess[7] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.7}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",8)' title="检查打磨抛光"/>
                    </if>
                    <if condition="$orthosisProcess[8] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.8}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",9)' title="组装对线"/>
                    </if>
                    <if condition="$orthosisProcess[9] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.9}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",10)' title="半成品适配"/>
                    </if>
                    <if condition="$orthosisProcess[10] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.10}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",11)' title="穿戴及使用训练"/>
                    </if>
                    <if condition="$orthosisProcess[11] eq '1' && $vo['workorder_type'] elt '7'">
                        <img class="icon1-img" style="height: 50px;cursor: pointer;" src="/Template/images/{$processArr.11}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",12)' title="入库"/>
                    </if>

                    <if condition="$prosthesisProcess[0] eq '1' && $vo['workorder_type'] egt '8'">
                        <img style="height: 50px;;cursor: pointer;" src="/Template/images/{$processArr.0}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",1)' title="接受腔制作"/>
                    </if>
                    <if condition="$prosthesisProcess[1] eq '1' && $vo['workorder_type'] egt '8'">
                        <img style="height: 50px;;cursor: pointer;" src="/Template/images/{$processArr.1}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",2)' title="装配"/>
                    </if>
                    <if condition="$prosthesisProcess[2] eq '1' && $vo['workorder_type'] egt '8'">
                        <img style="height: 50px;;cursor: pointer;" src="/Template/images/{$processArr.2}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",3)' title="入库"/>
                    </if>
                </td>

                <td style="padding: 0px 2px 0px 2px;">
                    <if condition="$vo['status'] egt $statusEnum['WAITING_DISTPATCH']">
                        <!--a class="btn btn-success" href='{:U("workorder/viewworkorder",array("id"=>$vo["workorder_id"]))}'>接单</a>
                    <else/-->
                        <a class="btn btn-info" href='{:U("workorder/viewworkorder",array("id"=>$vo["workorder_id"]))}'>查看与打印</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-info">查看与打印</a>
                    </if>
                    <br/>
                    <php>
                        $prescriber = 0;
                        $employee_idArr = explode(',', $user['employee_id']);
                        foreach ($employee_idArr as $value) {
                            if($value == $vo['prescriber_id'] && $vo['status'] == '1'){
                                $prescriber = 1;
                            }
                        }
                        if($vo['status'] <= 1){
                            $prescriberText = "处方";
                        }
                        else{
                            $prescriber = 2;
                            $prescriberText = "已出处方";
                        }
                    </php>
                    <if condition="$prescriber eq 1">
                        <a class="btn btn-danger" href='{:U("workorder/rx",array("id"=>$vo["workorder_id"]))}'>{$prescriberText}</a>
                        <elseif condition="$prescriber eq 2"/>
                        <a disabled="disable" class="btn btn-danger">{$prescriberText}</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-danger">{$prescriberText}</a>
                    </if>
                    <br/>
                    <!--php>
                        $needProcess = "0";
                        for($i = 0; $i < 11; $i++){
                        if($processStatusArr[$i] != "1"){
                        $needProcess = "1";
                        }
                        }
                    </php>
                    <if condition="$needProcess eq '1' && $vo['status'] neq '-2'">
                        <a class="btn btn-info" href='{:U("workorder/process",array("id"=>$vo["workorder_id"],"home"=>"1"))}'>制作流程</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-info">制作流程</a>
                    </if>
                    <br/-->
                    <php>
                        $claimText = "领料";
                        $claimStatus = -1;
                        $role = explode(',',$user["role"]);
                        if(in_role($role,"8")){
                        if($vo["claim_status"] == -2 || isNullOrEmpty($vo["claim_status"])){
                        $claimText = "领料";
                        $claimStatus = 1;
                        }else{
                        $claimText = "已领料";
                        $claimStatus = 2;
                        }
                        }
                    </php>
                    <if condition="$claimStatus eq 1">
                        <a class="btn btn-info" href='{:U("workorder/claimMaterial",array("id"=>$vo["workorder_id"]))}' >{$claimText}</a>
                        <elseif condition="$claimStatus eq 2"/>
                        <a disabled="disable" class="btn btn-info">{$claimText}</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-info">{$claimText}</a>
                    </if>
                </td>
                <td style="padding: 0px 2px 0px 2px;">
                    <php>
                        $auditor = 0;
                        $role = explode(',',$user["role"]);
                        if(in_role($role,"9") &&  $vo["status"] > 1 ){
                            if($vo['audit_status'] != 1){
                                $statusArr=explode(",",$vo["process_status"]);
                                $auditor = 1;
                                $i = 0;
                                foreach ($statusArr as $statusValue) {
                                    if($orthosisProcess[$i] == "1" && $i < 10 && $statusValue != "1"){
                                    $auditor = 0;
                                    }
                                $i++;
                                }
                            }
                        }
                        if($vo['audit_status'] == 1){
                            $auditor = 2;
                            $auditorText = "已质量检验";
                        }
                        else
                        $auditorText = "质量检验";

                    </php>
                    <if condition="$auditor eq 1">
                        <a class="btn btn-info" href='{:U("workorder/audit",array("id"=>$vo["workorder_id"]))}' >{$auditorText}</a>
                        <elseif condition="$auditor eq 2"/>
                        <a disabled="disable" class="btn btn-info">{$auditorText}</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-info">{$auditorText}</a>
                    </if>
                    <br/>
                    <php>
                        $claimAuditText = "领料审核";
                        $claimAuditStatus = -1;
                        $role = explode(',',$user["role"]);
                        if(in_role($role,"4")){
                        if($vo["claim_status"] == -1){
                        $claimAuditText = "领料审核";
                        $claimAuditStatus = 1;
                        }
                        if($vo["claim_status"] == 1){
                        $claimAuditText = "领料反审核";
                        $claimAuditStatus = 1;
                        }
                        }
                    </php>
                    <if condition="$claimAuditStatus eq 1">
                        <a class="btn btn-info" href='{:U("workorder/claimMaterial",array("id"=>$vo["workorder_id"]))}'>{$claimAuditText}</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-info">{$claimAuditText}</a>
                    </if>
                    <br/>
                    <php>
                        $outstore = 0;
                        $outstoreText = "审核出库";
                    </php>
                    <php>
                        $outstoreText = "出库审核";
                        $outstoreStatus = -1;
                        $role = explode(',',$user["role"]);
                        if(in_role($role,"4")){
                        if($vo["workorder_status"] == 4 ||$vo["outstore_status"] != 1 ){
                        $outstoreText = "出库审核";
                        $outstoreStatus = 1;
                        }
                        if($vo["outstore_status"] == 1){
                        $outstoreText = "出库反审核";
                        $outstoreStatus = 1;
                        }
                        }
                    </php>
                    <if condition="$outstoreStatus eq 1">
                        <a class="btn btn-info" href='{:U("workorder/outstore",array("id"=>$vo["workorder_id"]))}'>{$outstoreText}</a>
                        <else/>
                        <a disabled="disable" style="background-color: #93949c" class="btn btn-info">{$outstoreText}</a>
                    </if>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>